# Maintainer: Balló György <ballogyor+arch at gmail dot com>

pkgname=offroad
pkgver=0.5
pkgrel=3
pkgdesc="Offline vector map display ported from OsmAnd"
arch=('any')
url="https://sourceforge.net/projects/offroadosm/"
license=('GPL')
depends=('hicolor-icon-theme' 'imagemagick' 'java-runtime<=11')
source=("https://downloads.sourceforge.net/offroadosm/OffRoad-bin-$pkgver.zip"
        "$pkgname.desktop"
        "$pkgname.appdata.xml"
        "$pkgname.sh")
sha256sums=('024cd2a61780e5612b88fce734342e6de93151b2db45924ca19311fbd2b2b82d'
            'a59f0a5ab10efe74cbf75d52fb78642c1106335dd3c192a083d185f0358faec2'
            '3e5836a968bca5589183e470a01f2af978a3fe6d16e4406928d971284e38e971'
            '533d09ac0b0b63522cfc96ac6b3eda7676221d3f51d5066587795f8f63a2562d')

prepare() {
  bsdtar -xf lib/Resources.jar offroad_icon.png
}

package() {
  install -Dm644 OffRoad.jar "$pkgdir/usr/share/java/$pkgname/$pkgname.jar"
  install -Dm644 -t "$pkgdir/usr/share/java/$pkgname/lib/" lib/*.jar
  install -Dm755 $pkgname.sh "$pkgdir/usr/bin/$pkgname"
  install -Dm644 $pkgname.desktop "$pkgdir/usr/share/applications/$pkgname.desktop"
  install -Dm644 $pkgname.appdata.xml "$pkgdir"/usr/share/metainfo/$pkgname.appdata.xml
  install -dm755 "$pkgdir"/usr/share/icons/hicolor/256x256/apps/
  convert offroad_icon.png +set date:create +set date:modify -background none -gravity center -extent 300x300 -resize 256x256 -alpha on "$pkgdir/usr/share/icons/hicolor/256x256/apps/$pkgname.png"
  install -Dm644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
}
